// 实现的业务
// 更新最后一次登录时间
//更新是否是今天第一次登录
let {
    user
} = require("../login/sign_schma.js");
module.exports = {
    // eslint-disable-next-line no-unused-vars
    userChage: function (req, res, err) {
        // let newTime = (req.body.newDate).split(" ")[0];
        let newTime = (req.body.newDate).split(" ")[0];

        user.find({
            user:req.body.user
        }).then((data) => {
            // console.log(data1[0].lastTime.split(" ")[0],"909090");
            let oldTime = data[0].lastTime.split(" ")[0];
            console.log(`最新登录的时间${newTime}`);
            console.log(`最后登录的时间${oldTime}`);
    
            let result = (newTime == oldTime);

            console.log(result);

            user.updateOne({
                user:req.body.user
            }, {
                $set: {
                    lastTime: req.body.newDate,
                    award: result
                }
            }).then((data2) => {
                console.log(data2, "更新用户数据");
            })
        })
        res.send(true)

    }
}